// scenic-detail.js
Page({
  data: {
    // 导航栏高度
    navHeight: 0,
    // 景点信息
    scenicSpot: null,
    // 景点数据
    scenicSpotsData: {
      1: {
        id: 1,
        name: "黑麋峰观景台",
        location: "黑麋峰山顶",
        image: "/images/景点-1.jpg",
        rating: 5,
        distance: "0.5km",
        description: "黑麋峰最高观景点，可俯瞰整个景区",
        details: "黑麋峰观景台位于海拔1200米的山顶，是观赏整个黑麋峰景区的最佳位置。从这里可以360度环视四周，远眺群山连绵，近看云海翻腾。观景台采用钢架结构，安全稳固，是游客必到的打卡地点。",
        tips: "建议在日出或日落时分前往，景色最佳。注意保暖，山顶风大。",
        openingHours: "全天开放",
        ticketPrice: "免费",
        bestTime: "日出、日落、云海天气"
      },
      2: {
        id: 2,
        name: "玻璃栈道",
        location: "黑麋峰半山腰",
        image: "/images/景点-2.jpg",
        rating: 4,
        distance: "1.2km",
        description: "刺激的玻璃栈道体验，感受高空漫步",
        details: "玻璃栈道全长200米，悬挂在悬崖峭壁之上，距离地面高度约100米。栈道采用高强度钢化玻璃建造，安全系数极高。行走在透明的玻璃上，脚下是万丈深渊，让人体验前所未有的刺激感。",
        tips: "恐高者请谨慎选择。建议穿防滑鞋，不要携带重物。",
        openingHours: "8:00-17:00",
        ticketPrice: "50元/人",
        bestTime: "晴天、无风天气"
      },
      3: {
        id: 3,
        name: "瀑布群",
        location: "黑麋峰山脚",
        image: "/images/景点-3.jpg",
        rating: 5,
        distance: "2.1km",
        description: "多级瀑布群，水声潺潺，景色优美",
        details: "黑麋峰瀑布群由多个大小不一的瀑布组成，总落差超过200米。瀑布从山顶倾泻而下，形成壮观的飞瀑景观。周围植被茂密，空气清新，是避暑纳凉的理想去处。",
        tips: "雨季水量充沛，景色更佳。注意防滑，不要靠近瀑布边缘。",
        openingHours: "全天开放",
        ticketPrice: "免费",
        bestTime: "雨季、夏季"
      },
      4: {
        id: 4,
        name: "森林步道",
        location: "黑麋峰山腰",
        image: "/images/景点-4.jpg",
        rating: 4,
        distance: "1.8km",
        description: "幽静的森林步道，适合徒步和拍照",
        details: "森林步道全长3公里，蜿蜒穿行在茂密的原始森林中。步道两旁古木参天，鸟语花香，是进行森林浴和生态观光的绝佳场所。步道坡度平缓，适合各年龄段游客。",
        tips: "建议携带水和简单食物。注意防蚊虫，穿舒适的运动鞋。",
        openingHours: "全天开放",
        ticketPrice: "免费",
        bestTime: "春秋季节、清晨"
      },
      5: {
        id: 5,
        name: "观景亭",
        location: "黑麋峰山顶",
        image: "/images/攻略照片1.jpg",
        rating: 3,
        distance: "0.8km",
        description: "古色古香的观景亭，休息观景两相宜",
        details: "观景亭采用传统中式建筑风格，亭内设有休息座椅。亭子四周视野开阔，是游客休息、拍照、观景的理想场所。亭内还设有简单的茶座服务。",
        tips: "亭内座位有限，高峰期需要排队。可以在此小憩，欣赏风景。",
        openingHours: "全天开放",
        ticketPrice: "免费",
        bestTime: "全天"
      }
    }
  },

  onLoad(options) {
    console.log('景点详情页面参数:', options)
    
    // 获取景点ID和名称
    const spotId = parseInt(options.id) || 1
    const spotName = decodeURIComponent(options.name || '')
    
    // 获取景点详细信息
    const scenicSpot = this.data.scenicSpotsData[spotId]
    if (scenicSpot) {
      this.setData({
        scenicSpot: scenicSpot
      })
    }
    
    this.initLayout()
  },

  // 初始化布局
  initLayout() {
    const systemInfo = wx.getSystemInfoSync()
    const windowHeight = systemInfo.windowHeight
    this.setData({
      viewportHeight: windowHeight
    })
  },

  // 导航栏高度变化事件
  onNavHeightChange(e) {
    const { totalHeight } = e.detail
    this.setData({
      navHeight: totalHeight
    })
  },

  // 返回上一页
  onBackToGuide() {
    wx.navigateBack({
      delta: 1,
      fail: () => {
        wx.redirectTo({ url: '/pages/routes/routes' })
      }
    })
  }
})
